import Ab_NativeClient_bA from "../../A-FRAME/common/NativeClient";
import { Ab_AudioManager_bA } from "../manager/audio-manager";
import { Ab_NCAPIStructMap_bA, Ab_NCAPIURI_bA, Ab_NCRequestParam_bA } from "./api.config.client";

export class Ab_ClientAPI_bA {
	private static Ab_send_bA<A extends Ab_NCAPIURI_bA>(api: A, data?: Ab_NCAPIStructMap_bA[A]['Ab_request_bA']['Ab_data_bA'], ccdata?: any){
		return Ab_NativeClient_bA.Ab_sendMessage_bA<Ab_NCAPIStructMap_bA[A]>(api, data, ccdata);
	}

	public static async Ab_GameType_bA(){
		return Ab_ClientAPI_bA.Ab_send_bA(Ab_NCAPIURI_bA.Ab_Type_bA).Ab_response_bA.then(res=>res.Ab_data_bA.Ab_type_bA);
	}

	/** 获取设备ID */
	public static async Ab_DeviceID_bA(){
		return Ab_ClientAPI_bA.Ab_send_bA(Ab_NCAPIURI_bA.Ab_DeviceID_bA)
		.Ab_response_bA
		.then(res=>res.Ab_data_bA);
	}

	/** 本地化接口 */
	public static async Ab_Local_bA(){
		return Ab_ClientAPI_bA.Ab_send_bA(Ab_NCAPIURI_bA.Ab_LOCAL_bA)
		.Ab_response_bA
		.then(res=>res.Ab_data_bA);
	}

	/** 广告请求 */
	public static async Ab_AD_bA(type: Ab_NCRequestParam_bA<Ab_NCAPIURI_bA.Ab_AD_bA, 'Ab_type_bA'>, test?: boolean){
		test = test ?? false;
		Ab_ClientAPI_bA.Ab_Float_bA();
		let struct = Ab_ClientAPI_bA.Ab_send_bA(Ab_NCAPIURI_bA.Ab_AD_bA, {Ab_type_bA: type}, abi.Ab_string_bA.Ab_random_bA(5, 36));
		if(test){}else{
			Ab_AudioManager_bA.Ab_pauseBgm_bA();
		}
		let status = (await struct.Ab_response_bA).Ab_data_bA.Ab_status_bA;
		if(test){}else{
			Ab_AudioManager_bA.Ab_playBGM_bA();
		}
		return status=='ad-over';
	}

	//设置剪切板
	public static async Ab_SetClipboard_bA(Ab_text_bA: Ab_NCRequestParam_bA<Ab_NCAPIURI_bA.Ab_SetClipboard_bA, 'Ab_text_bA'>){
		Ab_ClientAPI_bA.Ab_send_bA(Ab_NCAPIURI_bA.Ab_SetClipboard_bA, {Ab_text_bA});
	}

	/**
	 * 在浏览器中打开一个指定的链接
	 * @param url
	 * @returns
	 */
	public static async Ab_Link_bA(url: Ab_NCRequestParam_bA<Ab_NCAPIURI_bA.Ab_LINK_bA, 'Ab_url_bA'>){
		Ab_ClientAPI_bA.Ab_send_bA(Ab_NCAPIURI_bA.Ab_LINK_bA, {Ab_url_bA: url});
	}

	public static async Ab_Float_bA(){
		Ab_ClientAPI_bA.Ab_send_bA(Ab_NCAPIURI_bA.Ab_Float_bA);
	}

	/** 评分弹窗 */
	public static async Ab_ScorePop_bA(){
		Ab_ClientAPI_bA.Ab_send_bA(Ab_NCAPIURI_bA.Ab_ScorePop_bA);
	}

	public static async Ab_CloseLoading_bA(){
		Ab_ClientAPI_bA.Ab_send_bA(Ab_NCAPIURI_bA.Ab_CloseLoading_bA);
	}
}
